
// 例子：
// timeFormat(dateObj, "yyyy-MM-dd hh:mm:ss.S") // ==> 2016-07-02 08:09:04.423
// timeFormat(dateObj, "yyyy-M-d h:m:s.S")      // ==> 2016-7-2 8:9:4.18
const timeFormat = (dateObj = new Date(), format = "yyyy-MM-dd hh:mm:ss") => {
    var date = {
        "M+": dateObj.getMonth() + 1,
        "d+": dateObj.getDate(),
        "h+": dateObj.getHours(),
        "m+": dateObj.getMinutes(),
        "s+": dateObj.getSeconds(),
        "q+": Math.floor((dateObj.getMonth() + 3) / 3),
        "S+": dateObj.getMilliseconds()
    };
    if (/(y+)/i.test(format)) {
        console.log('1',RegExp.$1)
        format = format.replace(RegExp.$1, (dateObj.getFullYear() + '').substr(4 - RegExp.$1.length));
    }
    for (var k in date) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1
                ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
        }
    }
    return format;
}

console.log(timeFormat(new Date(),"yyyy-M-d h:m:s.S"))


function numberFormat(value) {
    var param = {};
    var tempValue = 0;
    var k = 10000,
        sizes = ['', '万', '亿', '万亿'],
        i;
        if(value < k){
            param.value =value
            param.unit=''
        }else{
            i = Math.floor(Math.log(value) / Math.log(k)); 
            param.value = ((value / Math.pow(k, i))).toFixed(2);
            tempValue = param.value
            tempValue = tempValue.slice(tempValue.lastIndexOf(".") + 1)
            if(parseInt(tempValue) === 0) {
                param.value = parseInt(param.value)
            }
            param.unit = sizes[i];
        }
    return param.value + param.unit;
}


